<template>
  <div>
    <el-form class="others" :model="othersForm" :rules="others" inline label-width="120px">
      <h4 class="title"><span /><b>Suwork配置</b> </h4>

      <el-form-item label="Suwork APPID" :prop="othersForm.baidu_others_account || othersForm.baidu_others_password || othersForm.baidu_others_token?'baidu_others_account':' '">
        <el-input v-model="othersForm.suwork_appid" class="left" placeholder="请输入appid" type="password" />
      </el-form-item>
      <el-form-item label="Suwork 密钥" :prop="othersForm.baidu_others_account || othersForm.baidu_others_password || othersForm.baidu_others_token?'baidu_others_password':' '">
        <el-input v-model="othersForm.suwork_secret" class="right" placeholder="请输入密钥" type="password" />
      </el-form-item>

      <h4 class="title"><span /><b>5118关键词排名查询配置</b> </h4>
      <!-- <el-form-item label="自动查询频率">
        <el-select v-model="othersForm.keywords_search_time">
          <el-option label="每小时" value="hour" />
          <el-option label="每天" value="day" />
          <el-option label="每周" value="week" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="百度PC">
        <el-input v-model="othersForm.five_baidu_pc" type="password" />
      </el-form-item>
      <el-form-item label="百度移动">
        <el-input v-model="othersForm.five_baidu_mob" type="password" />
      </el-form-item>
      <el-form-item label="360PC">
        <el-input v-model="othersForm.haosou_pc" type="password" />
      </el-form-item>
      <el-form-item label="搜狗移动">
        <el-input v-model="othersForm.sougou_mob" type="password" />
      </el-form-item>
      <!-- <el-form-item label="站长工具" :prop="othersForm.google_others_token || othersForm.google_others_account || othersForm.google_others_password?'google_others_account':' '">
        <el-input v-model="othersForm.toolz" class="left" placeholder="请输入账号" />
      </el-form-item>
      <el-form-item label="5118" :prop="othersForm.google_others_token || othersForm.google_others_account || othersForm.google_others_password?'google_others_password':' '">
        <el-input v-model="othersForm.google_others_password" class="right" placeholder="请输入密码" type="password" />
      </el-form-item> -->
      <!-- <h4 class="title"><span /><b>谷歌翻译配置</b> </h4>
      <el-form-item label="谷歌翻译 Token" :prop="othersForm.google_trans_token || othersForm.google_others_account || othersForm.google_others_password?'google_others_account':' '">
        <el-input v-model="othersForm.toolz" class="left" placeholder="请输入token" type="password" />
      </el-form-item> -->
      <el-form-item label=" ">
        <el-button type="primary" class="save" @click="saveOthers">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import systemApi from '@/api/system/system'
export default {
  props: ['data'],
  data() {
    return {
      othersForm: {
        group: this.data.group,
        suwork_appid: '',
        suwork_secret: '',
        keywords_search_time: '',
        five_baidu_pc: '',
        five_baidu_mob: '',
        haosou_pc: '',
        sougou_mob: ''
      },
      others: {

      },
      filesData: ''
    }
  },
  created() {
    this.filesData = this.data.children

    this.filesData.forEach(el => {
      if (el.children.length > 0) {
        el.children.forEach(item => {
          if (item.children.length > 0) {
            item.children.forEach(element => {
              this.othersForm[element.title] = element.value
            })
          } else {
            this.othersForm[item.title] = item.value
          }
        })
      } else if (el.children.length == 0) {
        this.othersForm[el.title] = el.value
      }
    })
  },
  methods: {
    saveOthers() {
      systemApi.sysUpdate({ ...this.othersForm }).then(res => {
        if (res.code == 0) {
          this.$message.success(res.msg)
        } else {
          this.$message.error(res.msg)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
